package com.geotmt.billingcenter.modules.designmode.service;

import com.geotmt.billingcenter.common.enumpackage.ConsumeFeeFlagEnum;
import com.geotmt.billingcenter.common.enumpackage.CostFeeFlagEnum;
import com.geotmt.billingcenter.common.vo.params.RuleVo;
import com.geotmt.billingcenter.modules.designmode.rulesfactory.impl.AmountBilling;
import com.geotmt.billingcenter.modules.designmode.rulesfactory.impl.RulesContext;
import com.geotmt.billingcenter.modules.designmode.rulesfactory.impl.StairBilling;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * @Description
 * @Author      yanghanwei
 * @Mail        yanghanwei@geotmt.com
 * @Date        2019/3/25 14:22
 * @Version     v1
 **/
@Component
public class RulesStrategy {

    private static final Logger logger = LoggerFactory.getLogger(RulesStrategy.class);

    public Double getMoney(Integer feeFlag, RuleVo ruleVo) throws Exception{
        logger.info("策略 Service :feeFlag:{},ruleVo:{}",feeFlag,ruleVo);
        Double money = 0d;
        if(ConsumeFeeFlagEnum.AMOUNT.value.equals(feeFlag) || CostFeeFlagEnum.AMOUNT.value.equals(feeFlag)){
            logger.info("按量计费的工厂");
            money = new RulesContext(new AmountBilling()).getMoney(ruleVo);
        }else if(ConsumeFeeFlagEnum.STAIR.value.equals(feeFlag) || CostFeeFlagEnum.STAIR.value.equals(feeFlag)){
            logger.info("阶梯计费的工厂");
            money = new RulesContext(new StairBilling()).getMoney(ruleVo);
        }else{
            logger.info("没有该类型的工厂");
        }
        return money;
    }
}
